﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows.Media;

namespace TouchUmlUI
{
    public class AppMenu : Canvas
    {

        private HoverButton diagClass;
        private HoverButton diagInter;
        private HoverButton validate;
        private HoverButton separator;
        private HoverButton exit;
        private Window1 windowParent;

        ~AppMenu()
        {
            diagClass = null;
            diagInter = null;
            validate = null;
            separator = null;
            exit = null;
        }

        public AppMenu(Window1 windowParent, double px, double py)
        {
            this.windowParent = windowParent;
            InkCanvas.SetLeft(this, px);
            InkCanvas.SetTop(this, py);

            diagClass = new HoverButton("ikony\\icon_diagramklas.png", "ikony\\icon_diagramklashover.png", 239, 44);
            diagInter = new HoverButton("ikony\\icon_diagraminterakcji.png", "ikony\\icon_diagraminterakcjihover.png", 239, 44);
            validate = new HoverButton("ikony\\icon_walidujmodel.png", "ikony\\icon_walidujmodelhover.png", 239, 44);
            separator = new HoverButton("ikony\\icon_appmenuseparator.png", "ikony\\icon_appmenuseparator.png", 239, 44);
            exit = new HoverButton("ikony\\icon_wyjdz.png", "ikony\\icon_wyjdzhover.png", 239, 44);

            //diagClass.addClickHandler(windowParent.diagramKlas_Click);
            //diagInter.addClickHandler(windowParent.diagramInterakcji_Click);
            validate.addClickHandler(windowParent.walidujModel_Click);
            exit.addClickHandler(windowParent.exitApp_Click);

            HoverButton[] tab = { diagClass, diagInter, validate, separator, exit };

            for (int i = 0; i < tab.Length; i++)
            {
                Canvas.SetLeft(tab[i], 0);
                Canvas.SetTop(tab[i], i * 30);
                tab[i].Opacity = 0.0f;
                this.Children.Add(tab[i]);
            }
            
            DoubleAnimation[] dAnim = new DoubleAnimation[tab.Length];
            for (int i = 0; i < dAnim.Length; i++)
            {
                dAnim[i] = new DoubleAnimation();
                dAnim[i].From = 0.0f;
                dAnim[i].BeginTime = new TimeSpan(0, 0, 0, 0, 30 * i);
                dAnim[i].To = 1.0f;
                dAnim[i].Duration = new TimeSpan(0, 0, 0, 0, 200);                
                tab[i].BeginAnimation(Canvas.OpacityProperty, dAnim[i]);                
            }
            dAnim = null;
        }

    }
}
